home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / Asymptote Demo / Examples / Demos / 3) Hyperbola / demo3
Encoding:
Text File  |  1994-05-07  |  1.4 KB  |  82 lines  |  [TEXT/DWat]

  1. % Plot a hyperpola with asyptotes
  2. % You can alter the a and b values for the parabola
  3. set a 1
  4. set b 1
  5.  
  6. % Find the focus
  7. set c a a * b b * + sqrt
  8. npts 100
  9. graphlimits -3 a * 3 a * -3 a * 3 a *
  10. graphframe 1 6 1 6
  11. fullscreen yes
  12. fontname times
  13. fontsize 10
  14.  
  15. % Calculate the Hyperbola in each quadrant
  16. % and plot as a blue line
  17. pensize 2
  18. pencolor blue
  19. xrange a xright
  20. rpn <x dup * a dup * / 1 - b dup * * sqrt >y
  21. plotline
  22. % Flip it about the x axis to draw the 
  23. % other half of the curve
  24. rpn <y -1 * >y
  25. plotline
  26.  
  27. xrange "a -1 *" xleft
  28. rpn <x dup * a dup * / 1 - b dup * * sqrt >y
  29. plotline
  30. rpn <y -1 * >y
  31. plotline
  32.  
  33. % Draw the asymptotes to the hyperbola
  34. cliptoframe false
  35. pencolor red
  36. pensize 1
  37. moveto xleft xleft b * a /
  38. drawto xright xright b * a /
  39. moveto xleft xleft b * a / -1 *
  40. drawto xright xright b * a / -1 *
  41. pensize 0.25
  42. pencolor black
  43.  
  44. % Draw some labels
  45. moveto xleft 0
  46. drawarrowto xright 0
  47. moveto 0 ybottom
  48. drawarrowto 0 ytop
  49.  
  50. cliptoframe false
  51. moveto 0 ytop 1.05 *
  52. drawlabel 8 \iy
  53. moveto xright 1.05 * 0
  54. drawlabel 6 \ix
  55.  
  56. % Draw some lines to show x = -1 and x = +a
  57. pencolor 50 50 50  % 50% gray
  58. pendash 2
  59. set n npts xright a / / int
  60. moveto c -1 * 0
  61. drawto x(n) y(n)
  62. drawto c 0
  63.  
  64. moveto x(n) y(n)
  65. drawlabel 4 \iP(\ix,\iy)  
  66. moveto c -1 * .05
  67. drawlabel 8 \iF\d1(-\ic,0)
  68. moveto c .05
  69. drawlabel 8 \iF\d2(\ic,0)
  70.  
  71. pendash solid
  72. moveto a -1 * ybottom
  73. drawto a -1 * ytop .9 *
  74. drawlabel 8 \ix = -\ia
  75.  
  76. moveto a ybottom
  77. drawto a ytop .9 *
  78. drawlabel 8 \ix = -\ia
  79.  
  80. close xrange
  81.  
  82.